/**
 * File: application.hpp
 * Desc: Application类，用于初始化应用程序和运行程序
 * Author: JakeYang
 * Log: 20160113
 */


#ifndef __APPLICATION_HPP__
#define __APPLICATION_HPP__

#include <object.hpp>

namespace gtkhpp {

class Application : public Object {
public:
    Application(int *argc, char ***argv);
    void run() { gdk_threads_enter(); gtk_main(); gdk_threads_leave();}
    void quit() { gtk_main_quit(); }
protected:
    Application(Object *parent):Object(parent){}
};

inline Application::Application(int *argc, char ***argv)
    : Object(NULL)
{
#if (GTK_MAJOR_VERSION < 2) || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 32)
    g_thread_init(NULL);
#endif
    gdk_threads_init();
    gtk_init(argc, argv);
}

} // namespace gtkhpp

#endif /* end of include guard */
